#ifndef ADDRESSBOOK_H
#define ADDRESSBOOK_H

#include <QWidget>
#include <QMap>
#include "finddialog.h"

class QLabel;
class QLineEdit;
class QTextEdit;
class QPushButton;

class AddressBook:public QWidget{
    Q_OBJECT
public:
    AddressBook(QWidget *parent=0);

private:
    QLineEdit *nameLine;
    QTextEdit *addressText;

    QPushButton *addButton;
    QPushButton *submitButton;
    QPushButton *cancelButton;
    QPushButton *nextButton;
    QPushButton *previousButton;
    QPushButton *editButton;
    QPushButton *removeButton;
    QPushButton *findButton;
    QPushButton *loadButton;
    QPushButton *saveButton;
    FindDialog *dialog;

    QMap<QString,QString> contacts;
    QString oldName;
    QString oldAddress;

    enum Mode{NavigationMode,AddingMode,EditingMode};
    Mode currentMode;

    void updateInterface(Mode mode);

public slots:
    void addContact();
    void submitContact();
    void cancel();
    void next();
    void previous();
    void editContact();
    void removeContact();
    void findContact();
    void saveToFile();
    void loadFromFile();
};

#endif // ADDRESSBOOK_H
